import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:xvideos/assets_tool/images.dart';
import 'package:xvideos/routers/jump_router.dart';
import 'package:xvideos/tools_base/global_store/local_ads_info_store.dart';
import 'package:xvideos/hj_utils/widget_utils.dart';
import 'package:video_player/video_player.dart';

import '../../../hj_model/splash/ads_model.dart';
import '../../../tools_base/widget/marquee_widget.dart';

class ShortTxtAdWidget extends StatelessWidget {
  final VideoPlayerController? controller;

  List<AdsInfoModel> get adv => getAdvByTypeSync(33);

  const ShortTxtAdWidget({super.key, this.controller});

  @override
  Widget build(BuildContext context) {
    if (adv.isEmpty) return SizedBox();
    return Container(
      height: 40.h,
      padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 18.w),
      color: Colors.white.withOpacity(0.05),
      child: Row(
        children: [
          SvgPicture.asset(
            "hot_icon.svg".videoPath,
            width: 24.w,
            height: 24.w,
          ),
          2.sizeBoxW,
          Expanded(
            child: MarqueeWidget(
              count: adv.length,
              itemBuilder: (BuildContext context, int index) {
                AdsInfoModel bean = adv[index];
                return GestureDetector(
                  onTap: () {
                    pushToPageByLink(bean.href, id: bean.id);
                  },
                  child: Text(
                    bean.title ?? '',
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      color: Colors.white.withOpacity(0.6),
                      fontSize: 14.sp,
                    ),
                  ),
                );
              },
            ),
          ),
          4.sizeBoxW,
          Image.asset(
            'arrow_right_grey.webp'.commonImgPath,
            color: Colors.white,
            width: 24.w,
            height: 24.w,
          )
        ],
      ),
    );
  }
}
